import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Rectangle;


public class Circle
{
	private int x;
	private int y;
	private int size;
	private Color color;
	
	/**
	 * 
	 * @param x the x coordinate 
	 * @param y the y coordinate
	 * @param size  the diameter of the circle
	 */
	public Circle(int x, int y, int size)
	{
		this(Color.BLACK, x, y, size);
	}
	
	/**
	 * 
	 * @param color the color of the circle
	 * @param x the x coordinate 
	 * @param y the y coordinate
	 * @param size  the diameter of the circle
	 */
	public Circle(Color color, int x, int y, int size)
	{
		this.color= color;
		this.x= x;
		this.y= y;
		this.size= size;
	}
	
	/**
	 * Draws the circle as in Graphics2D.fillOval 
	 * 
	 * @param g the Graphics context
	 */
	public void drawCircle(Graphics g)
	{
		Graphics2D g2= (Graphics2D)g;
		Color oldColor= g.getColor();
		g.setColor(color);
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                			RenderingHints.VALUE_ANTIALIAS_ON);
		g2.fillOval(x, y, size, size);
		g.setColor(oldColor);
	}
	
	/**
	 * Tests weather or not the circle overlaps otherCircle
	 * @param otherCircle
	 * @return true if the otherCircle overlaps this
	 */
	public boolean isOverlapping(Circle otherCircle)
	{
		if(otherCircle==null) return false;
		Rectangle r1= new Rectangle(this.x, this.y, this.size, this.size);
		Rectangle r2= new Rectangle(otherCircle.x, otherCircle.y, otherCircle.size,
									otherCircle.size);
		return r1.intersects(r2);
	}

	public int getX() 
	{
		return x;
	}

	public void setX(int x) 
	{
		this.x = x;
	}

	public int getY() 
	{
		return y;
	}

	public void setY(int y) 
	{
		this.y = y;
	}

	public int getSize() 
	{
		return size;
	}

	public void setSize(int size) 
	{
		this.size = size;
	}
	
	public void setColor(Color color)
	{
		this.color= color;
	}
	
	public Color getColor()
	{
		return color;
	}
}
